<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title></title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
    <template id='loginTemp'>
        <div v-if='flag'>
            <button @click='changeFlag'>改变</button>
            我是登录组件
        </div>
        <div v-else>
            <button @click='changeFlag'>改变</button>
           lalallal
        </div>
    </template>
    <div id='app'>
        <button @click='flag=!flag'>切换login</button>
        <login v-if='flag'></login>
        lalla
        <login></login>
    </div>
    <script>
      
    const vm = new Vue({
        el: '#app',
        data: {
            flag:true
        },
        components:{
            login:{
                template:'#loginTemp',
                data(){
                    return{
                        flag:false
                    }
                },
                methods:{
                    changeFlag() {
                            this.flag = !this.flag
                        }
                }
            }
        }
    })
    </script>
</body>
</html>